package com.hsc.yalebao.newui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.text.format.DateUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.tabMine.WanFaActivity;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import org.json.JSONObject;

public class UpNewactivity extends BaseActivity
{
  private String TAG = "Upupactivity";
  private LinearLayout img_guanfang_chaxun;
  private LinearLayout img_kaijiang_zoushi;
  private LinearLayout img_wanfa_jieshao;
  private LinearLayout img_xiangguan_zixun;
  private PullToRefreshListView listview;
  private PullToRefreshListView listview2;
  private UpNewIndexAdapter mAdapter;
  private UpNewIndexAdapter mAdapter2;
  private String mCurrentQi = "";
  private int mDaojishi = 0;
  private List<Map<String, Object>> mDataList = new ArrayList();
  private List<Map<String, Object>> mDataList2 = new ArrayList();
  long mExitTime = 0L;
  private Handler mHandler = new Handler();
  private Handler mHandler2 = new Handler();
  private int mPage = 1;
  private int mPageSize = 20;
  private String mType = "1";
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131100354:
        Intent localIntent4;
        if (UpNewactivity.this.mType.equals("1"))
        {
          localIntent4 = new Intent(UpNewactivity.this, WanFaActivity.class);
          localIntent4.putExtra("instructionType", UpNewactivity.this.mType);
        }
        while (true)
        {
          UpNewactivity.this.startActivity(localIntent4);
          return;
          localIntent4 = new Intent(UpNewactivity.this, WanFaActivity.class);
          localIntent4.putExtra("instructionType", UpNewactivity.this.mType);
        }
      case 2131100355:
        Intent localIntent3;
        if (UpNewactivity.this.mType.equals("1"))
        {
          localIntent3 = new Intent(UpNewactivity.this, UpNewZoushituActivity.class);
          localIntent3.putExtra("lotteryid", "1");
        }
        while (true)
        {
          UpNewactivity.this.startActivity(localIntent3);
          return;
          localIntent3 = new Intent(UpNewactivity.this, UpNewZoushituActivity.class);
          localIntent3.putExtra("lotteryid", "3");
        }
      case 2131100356:
        Intent localIntent2 = new Intent(UpNewactivity.this, UpNewHtmlActivity.class);
        localIntent2.putExtra("url", "http://www.bwlc.net");
        localIntent2.putExtra("type", 0);
        UpNewactivity.this.startActivity(localIntent2);
        return;
      case 2131100357:
      }
      Intent localIntent1 = new Intent(UpNewactivity.this, UpNewDongTaiActivity.class);
      UpNewactivity.this.startActivity(localIntent1);
    }
  };
  private RadioButton rb_title1;
  private RadioButton rb_title2;
  private RadioGroup rg_top_tag;
  Runnable runnable = new Runnable()
  {
    public void run()
    {
      UpNewactivity.this.mHandler.removeCallbacks(UpNewactivity.this.runnable);
      UpNewactivity.this.mHandler.postDelayed(UpNewactivity.this.runnable, 1000L);
      UpNewactivity localUpNewactivity = UpNewactivity.this;
      localUpNewactivity.mDaojishi = (-1 + localUpNewactivity.mDaojishi);
      if (UpNewactivity.this.mDaojishi <= 0)
      {
        UpNewactivity.this.tv_daojishi.setText("第" + UpNewactivity.this.mCurrentQi + "期开奖中...");
        UpNewactivity.this.mHandler2.postDelayed(UpNewactivity.this.runnable2, 5000L);
        return;
      }
      UpNewactivity.this.tv_daojishi.setText("第" + UpNewactivity.this.mCurrentQi + "期还有" + UpNewactivity.this.mDaojishi + "秒开奖");
    }
  };
  Runnable runnable2 = new Runnable()
  {
    public void run()
    {
      UpNewactivity.this.mHandler2.removeCallbacks(UpNewactivity.this.runnable2);
      if (UpNewactivity.this.mDaojishi <= 0)
      {
        UpNewactivity.this.mHandler2.postDelayed(UpNewactivity.this.runnable2, 5000L);
        UpNewactivity.this.getData(UpNewactivity.this.mType);
      }
    }
  };
  private TextView tv_daojishi;

  private void getData(String paramString)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("page_no", this.mPage);
    localHashMap.put("page_size", this.mPageSize);
    localHashMap.put("type", paramString);
    UpNewUtils.post2(this, "http://www.dandan28kai.com/api.php", localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        UpNewactivity.this.listview.onRefreshComplete();
        LogUtils.e(UpNewactivity.this.TAG, "获取失败,获取banner:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        LogUtils.d(UpNewactivity.this.TAG, "result:" + paramAnonymousString);
        UpNewactivity.this.listview.onRefreshComplete();
        Map localMap1 = UpNewactivity.getMapForJson(paramAnonymousString);
        Map localMap2 = UpNewactivity.getMapForJson(localMap1.get("data"));
        Map localMap3 = UpNewactivity.getMapForJson(localMap2.get("current"));
        UpNewactivity.this.mDaojishi = Integer.valueOf(localMap3.get("left_time")).intValue();
        UpNewactivity.this.mCurrentQi = localMap3.get("issue");
        if (UpNewactivity.this.mDaojishi <= 0)
        {
          UpNewactivity.this.tv_daojishi.setText("第" + UpNewactivity.this.mCurrentQi + "期开奖中...");
          UpNewactivity.this.mHandler2.postDelayed(UpNewactivity.this.runnable2, 5000L);
        }
        while (true)
        {
          UpNewactivity.this.mHandler.postDelayed(UpNewactivity.this.runnable, 1000L);
          List localList = UpNewactivity.getlistForJson(localMap2.get("list"));
          UpNewactivity.this.listview.setVisibility(0);
          UpNewactivity.this.listview2.setVisibility(8);
          if (UpNewactivity.this.mPage == 1)
            UpNewactivity.this.mDataList.clear();
          UpNewactivity.this.mDataList.addAll(localList);
          if (UpNewactivity.this.mAdapter != null)
            break;
          UpNewactivity.this.mAdapter = new UpNewIndexAdapter(UpNewactivity.this.mDataList, UpNewactivity.this);
          UpNewactivity.this.listview.setAdapter(UpNewactivity.this.mAdapter);
          return;
          UpNewactivity.this.tv_daojishi.setText("第" + UpNewactivity.this.mCurrentQi + "期还有" + UpNewactivity.this.mDaojishi + "秒开奖");
        }
        UpNewactivity.this.mAdapter.notifyDataSetChanged();
      }
    });
  }

  public static Map<String, Object> getMapForJson(String paramString)
  {
    try
    {
      JSONObject localJSONObject = new JSONObject(paramString);
      Iterator localIterator = localJSONObject.keys();
      HashMap localHashMap = new HashMap();
      while (true)
      {
        if (!localIterator.hasNext())
          return localHashMap;
        String str = (String)localIterator.next();
        localHashMap.put(str, localJSONObject.get(str));
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return null;
  }

  // ERROR //
  public static List<Map<String, Object>> getlistForJson(String paramString)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: new 212	org/json/JSONArray
    //   5: dup
    //   6: aload_0
    //   7: invokespecial 213	org/json/JSONArray:<init>	(Ljava/lang/String;)V
    //   10: astore_2
    //   11: new 58	java/util/ArrayList
    //   14: dup
    //   15: invokespecial 59	java/util/ArrayList:<init>	()V
    //   18: astore_3
    //   19: iconst_0
    //   20: istore 4
    //   22: iload 4
    //   24: aload_2
    //   25: invokevirtual 217	org/json/JSONArray:length	()I
    //   28: if_icmplt +5 -> 33
    //   31: aload_3
    //   32: areturn
    //   33: aload_3
    //   34: aload_2
    //   35: iload 4
    //   37: invokevirtual 220	org/json/JSONArray:get	(I)Ljava/lang/Object;
    //   40: checkcast 183	org/json/JSONObject
    //   43: invokevirtual 221	org/json/JSONObject:toString	()Ljava/lang/String;
    //   46: invokestatic 223	com/hsc/yalebao/newui/UpNewactivity:getMapForJson	(Ljava/lang/String;)Ljava/util/Map;
    //   49: invokeinterface 229 2 0
    //   54: pop
    //   55: iinc 4 1
    //   58: goto -36 -> 22
    //   61: astore 5
    //   63: aload 5
    //   65: invokevirtual 208	java/lang/Exception:printStackTrace	()V
    //   68: aload_1
    //   69: areturn
    //   70: astore 5
    //   72: aload_3
    //   73: astore_1
    //   74: goto -11 -> 63
    //
    // Exception table:
    //   from	to	target	type
    //   2	19	61	java/lang/Exception
    //   22	31	70	java/lang/Exception
    //   33	55	70	java/lang/Exception
  }

  private void init()
  {
    this.listview = ((PullToRefreshListView)findViewById(2131099717));
    this.listview2 = ((PullToRefreshListView)findViewById(2131100359));
    initRefresh();
    this.img_wanfa_jieshao = ((LinearLayout)findViewById(2131100354));
    this.img_kaijiang_zoushi = ((LinearLayout)findViewById(2131100355));
    this.img_guanfang_chaxun = ((LinearLayout)findViewById(2131100356));
    this.img_xiangguan_zixun = ((LinearLayout)findViewById(2131100357));
    this.img_wanfa_jieshao.setOnClickListener(this.onClickListener);
    this.img_kaijiang_zoushi.setOnClickListener(this.onClickListener);
    this.img_guanfang_chaxun.setOnClickListener(this.onClickListener);
    this.img_xiangguan_zixun.setOnClickListener(this.onClickListener);
    this.tv_daojishi = ((TextView)findViewById(2131100358));
    this.rg_top_tag = ((RadioGroup)findViewById(2131099835));
    this.rb_title1 = ((RadioButton)findViewById(2131099836));
    this.rb_title2 = ((RadioButton)findViewById(2131099837));
    this.rg_top_tag.check(2131099836);
    this.rg_top_tag.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
    {
      public void onCheckedChanged(RadioGroup paramAnonymousRadioGroup, int paramAnonymousInt)
      {
        switch (paramAnonymousInt)
        {
        default:
          return;
        case 2131099836:
          UpNewactivity.this.mHandler.removeCallbacks(UpNewactivity.this.runnable);
          UpNewactivity.this.mType = "1";
          UpNewactivity.this.mPage = 1;
          UpNewactivity.this.getData("1");
          return;
        case 2131099837:
        }
        UpNewactivity.this.mHandler.removeCallbacks(UpNewactivity.this.runnable);
        UpNewactivity.this.mType = "2";
        UpNewactivity.this.mPage = 1;
        UpNewactivity.this.getData("2");
      }
    });
  }

  private void initRefresh()
  {
    this.listview.setMode(PullToRefreshBase.Mode.BOTH);
    this.listview.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(UpNewactivity.this, System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (UpNewactivity.this.listview.isHeaderShown())
          LogUtils.e(UpNewactivity.this.TAG, "mPullRefreshListView刷新");
        UpNewactivity localUpNewactivity;
        for (UpNewactivity.this.mPage = 1; ; localUpNewactivity.mPage = (1 + localUpNewactivity.mPage))
        {
          UpNewactivity.this.getData(UpNewactivity.this.mType);
          return;
          LogUtils.e(UpNewactivity.this.TAG, "mPullRefreshListView加载");
          localUpNewactivity = UpNewactivity.this;
        }
      }
    });
    this.listview2.setMode(PullToRefreshBase.Mode.BOTH);
    this.listview2.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(UpNewactivity.this, System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (UpNewactivity.this.listview2.isHeaderShown())
          LogUtils.e(UpNewactivity.this.TAG, "mPullRefreshListView刷新");
        UpNewactivity localUpNewactivity;
        for (UpNewactivity.this.mPage = 1; ; localUpNewactivity.mPage = (1 + localUpNewactivity.mPage))
        {
          UpNewactivity.this.getData("2");
          return;
          LogUtils.e(UpNewactivity.this.TAG, "mPullRefreshListView加载");
          localUpNewactivity = UpNewactivity.this;
        }
      }
    });
  }

  public boolean dispatchKeyEvent(KeyEvent paramKeyEvent)
  {
    if ((paramKeyEvent.getKeyCode() == 4) && (paramKeyEvent.getAction() == 0) && (paramKeyEvent.getRepeatCount() == 0))
    {
      if (System.currentTimeMillis() - this.mExitTime > 2000L)
      {
        UiUtil.showToast(this, "再按一次退出");
        this.mExitTime = System.currentTimeMillis();
        return true;
      }
      CustomApplication.app.finishAllActivity();
      finish();
      Process.killProcess(Process.myPid());
      System.exit(0);
      return true;
    }
    return super.dispatchKeyEvent(paramKeyEvent);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    CustomApplication.app.addActivity(this);
    setContentView(2130903223);
    init();
    getData("1");
  }

  protected void onResume()
  {
    super.onResume();
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.newui.UpNewactivity
 * JD-Core Version:    0.6.2
 */